home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Alles Voor Internet / Tout Pour Internet
/
alles voor internet.iso
/
MacInternet™
/
Telnet
/
NCSA
/
tn3270 2.3d26 source
/
tn3270
/
cdialog.c
< prev
next >
Wrap
Text File
|
1991-05-16
|
10KB
|
425 lines
/*
* tn3270 for the Macintosh Source Code
* Brown University Computing and Information Services
* Version 2.3d21, January 17, 1991
* Copyright (c) 1988, 1989, 1990, 1991 by Brown University and by
* Peter John DiCamillo.
*
* Permission is granted to any individual or institution to use, copy,
* or redistribute the binary version of this software and its
* documentation provided this notice and the copyright notices are
* retained. Permission is granted to any individual or non-profit
* institution to use, copy, modify, or redistribute the source files
* of this software provided this notice and the copyright notices are
* retained. This software may not be distributed for profit, either
* in original form or in derivative works, nor can the source be
* distributed to other than an individual or a non-profit institution.
* Any individual or group interested in seeing and/or using these
* source files but who are prevented from doing so by the above
* constraints should contact Don Wolfe, Assistant Vice-President for
* Computer Systems at Brown University, (401) 863-7250, for possible
* software licensing of the source developed at Brown.
*
* Brown University and Peter John DiCamillo make no representations
* about the suitability of this software for any purpose.
*
* BROWN UNIVERSITY AND PETER JOHN DICAMILLO GIVE NO WARRANTY, EITHER
* EXPRESS OR IMPLIED, FOR THE PROGRAM AND/OR DOCUMENTATION PROVIDED,
* INCLUDING, WITHOUT LIMITATION, WARRANTY OF MERCHANTABILITY AND
* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#define __SEG__ 3270seg2
#include "maclib.h"
#include "termdef.h"
#include "globals.h"
#define PICKERWIDTH 430
#define PICKERHEIGHT 282
extern PaletteHandle myPalette;
extern RGBColor realblack, realwhite;
PaletteHandle dlgpalette;
extern GDHandle bitmap_gdev; /* gdev used for bitmaps */
pascal Boolean myGETCOLOR(where,prompt,inColor,outColor,SW)
unsigned long where;
Str255 *prompt;
RGBColor *inColor;
RGBColor *outColor;
short SW;
extern 0xA82E;
colordlg()
{
DialogPtr dlgptr;
DialogPeek dStorage;
WindowPtr behind;
unsigned short (*filterProc) ();
short gtype;
Handle gitem, itmlist;
Rect gbox, mybox, dlgbox;
void (*myitem) ();
short i;
GrafPtr gp;
short itemHit;
short * itemHitPtr;
pascal unsigned short DlgFilter();
pascal void colorbox();
RGBColor in, out, actual;
char tbase, texact, tinvert;
RGBColor twhite, tyellow, tpink, tturquoise, tgreen,
tred, tblue, tblack, tback, tstat;
static RGBColor dwhite = DFLTWHITE;
static RGBColor dyellow = DFLTYELLOW;
static RGBColor dpink = DFLTPINK;
static RGBColor dturquoise = DFLTTURQUOISE;
static RGBColor dgreen = DFLTGREEN;
static RGBColor dred = DFLTRED;
static RGBColor dblue = DFLTBLUE;
static RGBColor dblack = DFLTBLACK;
static RGBColor dback = DFLTBACK;
static RGBColor ctdpink = CTDFLTPINK;
static RGBColor ctdturquoise = CTDFLTTURQUOISE;
static RGBColor ctdblue = CTDFLTBLUE;
static RGBColor ctdback = CTDFLTBACK;
RGBColor rgbtemp;
GDHandle currGD;
PixMapHandle currPM;
short scrhsize, scrvsize;
short whsize, wvsize;
dStorage = 0;
behind = (WindowPtr)-1;
dlgbox.top = 16;
dlgbox.left = 44;
dlgbox.bottom = 326;
dlgbox.right = 469;
itmlist = GetResource('DITL', 268);
if (itmlist == 0) return;
HandToHand(&itmlist);
if (itmlist == 0) return;
dlgptr = NewCDialog(dStorage, &dlgbox, "Colors", 0, 3, behind,
0, 0L, itmlist);
/* center the dialog on the current gDevice */
if (myWindow != 0) {
gbox = (*bitmap_gdev)->gdRect;
}
else {
currGD = GetMainDevice();
gbox = (*currGD)->gdRect;
}
scrhsize = gbox.right - gbox.left;
scrvsize = gbox.bottom - gbox.top;
whsize = dlgptr->portRect.right-dlgptr->portRect.left;
wvsize = dlgptr->portRect.bottom - dlgptr->portRect.top;
MoveWindow(dlgptr, gbox.left + (scrhsize-whsize)/2,
gbox.top + (scrvsize-wvsize)/3, 0);
dlgpalette = NewPalette(11, 0L, pmCourteous, 0);
SetPalette(dlgptr, dlgpalette, true);
fixcolors(dlgpalette);
ActivatePalette(dlgptr);
/* define routine to draw user item */
myitem = colorbox;
for (i=5; i < 24; i+=2) {
GetDItem(dlgptr, i, >ype, &gitem, &mybox);
SetDItem(dlgptr, i, gtype, myitem, &mybox);
}
/* define check boxes */
defcbox(dlgptr);
arrowcursor();
ShowWindow(dlgptr);
/* frame the default selection */
GetDItem(dlgptr, 1, >ype, &gitem, &gbox);
GetPort(&gp);
SetPort(dlgptr);
PenSize(3,3);
InsetRect(&gbox, -4, -4);
FrameRoundRect(&gbox, 16, 16);
PenSize(1,1);
SetPort(gp);
itemHit = 99;
itemHitPtr = &itemHit;
filterProc = DlgFilter;
/* copy current settings */
tbase = cs.basecolor;
texact = cs.exactcolor;
tinvert = cs.invertbw;
twhite = cs.usrwhite;
tyellow = cs.usryellow;
tpink = cs.usrpink;
tturquoise = cs.usrturquoise;
tgreen = cs.usrgreen;
tred = cs.usrred;
tblue = cs.usrblue;
tblack = cs.usrblack;
tback = cs.usrback;
tstat = cs.usrstat;
while ((itemHit != 1) && (itemHit != 3)) {
ModalDialog(filterProc, itemHitPtr);
switch(itemHit) {
case 1: /* OK */
if (myWindow != 0) fixcolors(myPalette);
break;
case 2: /* Set Default */
cs.usrwhite = dwhite;
cs.usryellow = dyellow;
cs.usrgreen = dgreen;
cs.usrred = dred;
cs.usrblack = dblack;
if (cs.exactcolor) {
cs.usrpink = dpink;
cs.usrturquoise = dturquoise;
cs.usrblue = dblue;
cs.usrback = dback;
cs.usrstat = dblue;
}
else {
cs.usrpink = ctdpink;
cs.usrturquoise = ctdturquoise;
cs.usrblue = ctdblue;
cs.usrback = ctdback;
cs.usrstat = ctdblue;
}
if (!cs.exactcolor) {
cs.exactcolor = 1;
fixcolors(dlgpalette);
ActivatePalette(dlgptr);
cs.exactcolor = 0;
}
cs.basecolor = 0;
cs.invertbw = 0;
defcbox(dlgptr);
fixcolors(dlgpalette);
ActivatePalette(dlgptr);
if (myWindow != 0) {
GetEntryColor(dlgpalette, RGBback, &rgbtemp);
GetPort(&gp);
SetPort(WritePtr);
if (textmap) setgdev();
RGBBackColor(&rgbtemp);
if (PictPtr != 0) {
SetPort(PictPtr);
RGBBackColor(&rgbtemp);
}
if (textmap) resetgdev();
SetPort(gp);
}
updcolors(dlgptr);
break;
case 3: /* Cancel */
cs.basecolor = tbase;
cs.exactcolor = texact;
cs.invertbw = tinvert;
cs.usrwhite = twhite;
cs.usryellow = tyellow;
cs.usrpink = tpink;
cs.usrturquoise = tturquoise;
cs.usrgreen = tgreen;
cs.usrred = tred;
cs.usrblue = tblue;
cs.usrblack = tblack;
cs.usrback = tback;
cs.usrstat = tstat;
fixcolors(dlgpalette);
ActivatePalette(dlgptr);
if (myWindow != 0) {
GetEntryColor(dlgpalette, RGBback, &rgbtemp);
GetPort(&gp);
SetPort(WritePtr);
if (textmap) setgdev();
RGBBackColor(&rgbtemp);
if (PictPtr != 0) {
SetPort(PictPtr);
RGBBackColor(&rgbtemp);
}
if (textmap) resetgdev();
SetPort(gp);
}
break;
case 5: /* white */
case 6:
getclr(dlgptr, "white", &cs.usrwhite);
break;
case 7: /* yellow */
case 8:
getclr(dlgptr, "yellow", &cs.usryellow);
break;
case 9: /* turquoise */
case 10:
getclr(dlgptr, "turquoise", &cs.usrturquoise);
break;
case 11: /* green */
case 12:
getclr(dlgptr, "green", &cs.usrgreen);
break;
case 13: /* pink */
case 14:
getclr(dlgptr, "pink", &cs.usrpink);
break;
case 15: /* red */
case 16:
getclr(dlgptr, "red", &cs.usrred);
break;
case 17: /* blue */
case 18:
getclr(dlgptr, "blue", &cs.usrblue);
break;
case 19: /* black */
case 20:
getclr(dlgptr, "black", &cs.usrblack);
break;
case 21: /* background */
case 22:
getclr(dlgptr, "bkground", &cs.usrback);
GetEntryColor(dlgpalette, RGBback, &rgbtemp);
GetPort(&gp);
if (myWindow != 0) {
SetPort(WritePtr);
if (textmap) setgdev();
RGBBackColor(&rgbtemp);
if (textmap) resetgdev();
}
actualcolor(&rgbtemp, &actual);
if (actual == realwhite) {
cs.invertbw = 1;
defcbox(dlgptr);
}
else if (actual == realblack) {
cs.invertbw = 0;
defcbox(dlgptr);
}
if (PictPtr != 0) {
if (textmap) setgdev();
SetPort(PictPtr);
RGBBackColor(&rgbtemp);
if (textmap) resetgdev();
}
SetPort(gp);
break;
case 23: /* status line */
case 24:
getclr(dlgptr, "status", &cs.usrstat);
break;
case 25: /* base color */
cs.basecolor ^= 1;
defcbox(dlgptr);
break;
case 26: /* exact color */
cs.exactcolor ^= 1;
fixcolors(dlgpalette);
ActivatePalette(dlgptr);
updcolors(dlgptr);
defcbox(dlgptr);
break;
case 27: /* invert black and white */
cs.invertbw ^= 1;
defcbox(dlgptr);
break;
default:
break;
}
}
DisposDialog(dlgptr);
}
getclr(dlgptr, cname, cin)
DialogPtr dlgptr;
char * cname;
RGBColor *cin;
{
GrafPtr gp;
Point where;
short result;
short gtype;
Handle gitem;
Rect gbox;
char prompt[48];
RGBColor cout;
GDHandle currGD;
PixMapHandle currPM;
short scrhsize, scrvsize;
strcpy(prompt, "Select color for ");
strcat(prompt, cname);
strcat(prompt, ":");
GetPort(&gp);
if (myWindow != 0) {
SetPort(myWindow);
}
/* center color picker on current gDevice */
if (myWindow != 0) {
gbox = (*bitmap_gdev)->gdRect;
}
else {
currGD = GetMainDevice();
gbox = (*currGD)->gdRect;
}
scrhsize = gbox.right - gbox.left;
scrvsize = gbox.bottom - gbox.top;
where.h = gbox.left + (scrhsize-PICKERWIDTH)/2;
where.v = gbox.top + (scrvsize-PICKERHEIGHT)/3;
ctop(prompt);
result = GETCOLOR(where, prompt, cin, &cout);
ptoc(prompt);
if (result) {
*cin = cout;
fixcolors(dlgpalette);
ActivatePalette(dlgptr);
updcolors(dlgptr);
}
/* frame the default selection again */
GetDItem(dlgptr, 1, >ype, &gitem, &gbox);
SetPort(dlgptr);
PenSize(3,3);
InsetRect(&gbox, -4, -4);
FrameRoundRect(&gbox, 16, 16);
PenSize(1,1);
SetPort(gp);
}
defcbox(dlgptr)
DialogPtr dlgptr;
{
short gtype;
Handle gitem;
Rect gbox;
GetDItem(dlgptr, 25, >ype, &gitem, &gbox);
SetCtlValue(gitem, cs.basecolor);
GetDItem(dlgptr, 26, >ype, &gitem, &gbox);
SetCtlValue(gitem, cs.exactcolor);
GetDItem(dlgptr, 27, >ype, &gitem, &gbox);
SetCtlValue(gitem, cs.invertbw);
}
updcolors(dlgptr)
DialogPtr dlgptr;
{
Rect crect;
GrafPtr gp;
crect.top = 5;
crect.left = 5;
crect.bottom = 295;
crect.right = 100;
GetPort(&gp);
SetPort(dlgptr);
InvalRect(&crect);
SetPort(gp);
}